package cn.the.angry.tests;

import org.jbox2d.collision.AABB;
import org.jbox2d.collision.shapes.CircleDef;
import org.jbox2d.collision.shapes.PolygonDef;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.World;

import cn.the.angry.util.AngryPigDebugDraw;

public class AngryPigDebugDrawTest extends AbstractTest {
	
	private final int targetFPS = 40;
	private final int timeStep = (1000/targetFPS);
	private final int iteration = 5;
	
	private Body[] bodies;
	private int count = 0;
	
	private AABB worldAABB;
	private World mWorld;
	private BodyDef groundBodyDef;
	private PolygonDef groundShapeDef;
	
	

	public AngryPigDebugDrawTest(){
		super();
		
	}
	
	public void create(){
		worldAABB = new AABB();
		worldAABB.lowerBound.set(0, 0);
		worldAABB.upperBound.set(WIDTH, HEIGHT);
		
		mWorld = new World(worldAABB, new Vec2(0f, 10f), true);
		mWorld.setDebugDraw(new AngryPigDebugDraw(WIDTH, HEIGHT, 1f));
		
		CircleDef cd = new CircleDef();
		cd.density = 1f;
		cd.friction = 0.2f;
		cd.radius = 78f;  //should been modified..
		
		BodyDef ballDef = new BodyDef();
		mWorld.createBody(ballDef).createShape(cd);
		
		
	}
	
	
	public static void main(String[] args){
		AngryPigDebugDrawTest main = new AngryPigDebugDrawTest();
		main.setVisible(true);
		new Thread(new Runnable()
        {    
            @Override
            public void run()
            {
                for(;;)
                {
                	try
					{
						Thread.sleep(5);
					}
					catch (InterruptedException e)
					{
						e.printStackTrace();
					}
//            		main.step(timeStep, iteration);            		
                }
            }
            
        }).start();
	}
}
